package daos;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Conexao {

	private Connection con;
	
	private void abrirConexao(){
		
		try {
		
			Class.forName("com.mysql.jdbc.Driver");
			con = DriverManager.getConnection("jdbc:mysql://localhost:3306/associador_informacoes_dump","root","sarai");

		
		} catch (SQLException e) {
			e.printStackTrace();
		}
		catch(ClassNotFoundException a){
			a.printStackTrace();
		}
		
		
	}

	public void shutDown(){
		
		try{
			
			con.close();
			
		}catch(SQLException a){
			a.printStackTrace();
		}
	}
	
	public Connection getConexao(){
		
		if(con == null){
			abrirConexao();
		}
		
		return con;
	}
	
}
